package cn.gson.boot.model.dao;

import cn.gson.boot.model.pojos.Fahuo;
import cn.gson.boot.model.pojos.Huanhuo;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;

public interface HuanHuoDao extends CrudRepository<Huanhuo,Integer> {
    //移除（逻辑删除）
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update huanhuo set hh_ys=0 where hh_id=?1")
    public void yichuHuanHuo(Integer hhId);
    //删除换货
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "delete from huanhuo where hh_id=?1")
    public void deleteHuanHuo(Integer hhId);

    //审核
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update huanhuo set hh_sh=?1 where hh_id=?2")
    public void shenheHuanHuo(String ztai,Integer hhid);


    //修改换货单入库的状态
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update huanhuo set hh_rk=?1 where hh_id=?2")
    public void updateHuanHuoRuku(String hhRk,Integer hhId);


    //修改换货单维修完成的状态(-1=>没有,0=>维修中,1=>完成)
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update huanhuo set hh_wxwc=?1 where hh_id=?2")
    public void updateHuanWxwc(Integer wxwc,Integer hhId);
}
